import java.util.ArrayList;
import java.util.List;

public class Combine {
    static List<List<Integer>> res = new ArrayList<>();
    static List<Integer> path = new ArrayList<>();
    public static void dfs(int n,int k,int startIndex){
              if(path.size() == k){
            res.add(new ArrayList<>(path));
            return;
        }

        for (int i = startIndex ;i < n+1 ; i++){
            path.add(i);
            dfs(n,k,i+1);
            path.remove(path.size()-1);
        }
    }

    public static void main(String[] args) {
        dfs(4,2,1);
        res.forEach(r->{
            r.forEach(x->{
                System.out.print(x+"   ");
            });
            System.out.println("------------------------");
        });
    }
}
